<?php
namespace ZfcUser\Model;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;
class TsessionTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }	
	public	function updateUserID($session_id,$userId){	
		$resultSet=$this->tableGateway->update(array('user_id'=>$userId), array('id' => $session_id));	
		//echo "<pre>";print_r($resultSet);exit;
		return $resultSet;
	}
	public	function deleteExistsSession($session_id){	
		$resultSet=$this->tableGateway->delete(array('id'=>$session_id));	
		//echo "<pre>";print_r($resultSet);exit;
		return $resultSet;
	}
	public	function checkSessionExists($userId){	
			$select = $this->tableGateway->getSql()->select()
				->where("user_id='".$userId."'");				
		$resultSet = $this->tableGateway->selectWith($select);		
        return $resultSet;
	}
	
}